#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;

int a[210];

int main()
{
	int n, k;
	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}

	int maximum = -200001;
	for (int i = 0; i < n; ++i)
	{
		for (int j = i+1; j <= n; ++j)
		{
			int sum = 0;
			priority_queue<int, vector<int>, greater<int>> in;
			priority_queue<int> out;
			for (int m = 0; m < n; ++m)
				if (m >= i && m < j)
				{
					in.push(a[m]);
					sum += a[m];
				}
				else
					out.push(a[m]);

			// swap
			for (int kk = 0; kk < k; ++kk)
				if (!out.empty() && !in.empty() && out.top() > in.top())
				{
					sum += out.top() - in.top();

					in.push(out.top());
					out.push(in.top());

					in.pop(); out.pop();
				}

			maximum = max(maximum, sum);
		}
	}
		
	printf("%d\n", maximum);
}